--# -path=.:prelude

resource MorphoChi = open Prelude in {
 
  flags coding=utf8;
  -- the lexicon construction API

    oper
      mkN : overload {
        mkN : (wine : Str) -> (bottle : Str) -> Noun ;
      } ;

      mkA : Str -> Bool -> Adjective ;

      mkV : overload {
        mkV : (kiss : Str) -> Verb ;
      } ;

      mkV2 : overload {
        mkV2 : (love : Verb) -> Verb2 ;
        mkV2 : (talk : Verb) -> (about : Str) -> Verb2 ;
      } ;

  -- grammar-internal definitions

    param
      Number = Sg | Pl ;
      RelPart = De | NoRel ;


    oper
      Conjunction : Type = {s,s2,n,n2 : Str} ;
      Noun : Type = {s, cl : Str} ;
      Adjective : Type = {s : RelPart => Str ; cop : Bool} ;
      Determiner : Type = {s : Str ; n : Number ; cl : Bool} ;
      Verb : Type = {s : Str} ;
      Verb2 : Type = Verb ** {c : Str} ;

      mkN = overload {
        mkN : (_,_ : Str) -> Noun = mkNoun ;
      } ;

      --Adjectives are stative or verb-like; first ones act as predicatives with copula, second ones without.
      mkA : Str -> Bool -> Adjective = \adj,b -> {
         s = table {De    => adj + relationParticle ;
         	        NoRel => adj
         } ; 
         cop = b
      } ;

      mkV = overload {
        mkV : (kiss : Str) -> Verb = \s -> mkVerb s ;
      } ;

      mkV2 = overload {
        mkV2 : (love : Verb) -> Verb2 = \love -> love ** {c = []} ;
        mkV2 : (talk : Verb) -> (about : Str) -> Verb2 = 
          \talk,about -> talk ** {c = about} ;
      } ;

      --The noun and the classificator
      mkNoun : Str -> Str -> Noun = \n,cl ->
        {s = n ; cl = cl} ;

      --The verb
      mkVerb : Str -> Verb = \x ->
        {s = x} ;

-- Questions

    -- Question particle 'ma' added after a yes/no question
    questionParticle : Str = "吗" ;
    


-- Other

    negationParticle : Str = "不" ;
    -- Relation particle 的 "de" has many functions
    -- possession: "wǒ de" = my
    -- after modifier adjective: "piàoliang de rén" = beautiful person
    -- after nouns and stative adjectives as copula complements:
    --                           "wǒ shì piàoliang de" = I am beautiful
    relationParticle : Str = "的" ;
  }

